﻿using System;

namespace SmartCard.PcscApi
{
	//// <summary>
	//// Codes taken from the windows 7.0 SDK
	//// </summary>
	/// <summary>
	/// The below defines the meaning of the dwords
	/// 
	///
	///  Values are 32 bit values laid out as follows:
	///
	///   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
	///   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
	///  +---+-+-+-----------------------+-------------------------------+
	///  |Sev|C|R|     Facility          |               Code            |
	///  +---+-+-+-----------------------+-------------------------------+
	///
	///  where
	///
	///      Sev - is the severity code
	///
	///          00 - Success
	///          01 - Informational
	///          10 - Warning
	///          11 - Error
	///
	///      C - is the Customer code flag
	///
	///      R - is a reserved bit
	///
	///      Facility - is the facility code
	///
	///      Code - is the facility's status code
	///
	///
	/// Define the facility codes
	///
	/// </summary>
	internal enum ePcscErrors : long
	{
		/// <summary>
		/// SCARD_S_SUCCESS
		/// </summary>
		Success = 0x00000000,

		/// <summary>
		/// ERROR_INVALID_HANDLE
		/// </summary>
		Win32InvalidHandle = 0x00000006,

		/// <summary>
		/// ERROR_BAD_COMMAND
		/// </summary>
		Win32BadCommand = 0x00000016,

		/// <summary>
		/// ERROR_INVALID_PARAMETER
		/// </summary>
		Win32InvalidParameter = 0x00000057,

		/// <summary>
		/// SCARD_F_INTERNAL_ERROR, 
		/// An internal consistency check failed.
		/// </summary>
		InternalError = 0x80100001L,

		/// <summary>
		/// SCARD_E_CANCELLED, The action was cancelled by an SCardCancel request.
		/// </summary>
		Cancelled = 0x80100002L,

		/// <summary>
		/// SCARD_E_INVALID_HANDLE, The supplied handle was invalid.
		/// </summary>
		InvalidHandle = 0x80100003L,

		/// <summary>
		/// SCARD_E_INVALID_PARAMETER, 
		/// One or more of the supplied parameters could not be properly
		/// interpreted.
		/// </summary>
		InvalidParameter = 0x80100004L,

		/// <summary>
		/// SCARD_E_INVALID_TARGET
		/// Registry startup information is missing or invalid.
		/// </summary>
		InvalidTarget = 0x80100005L,

		/// <summary>
		/// SCARD_E_NO_MEMORY
		/// Not enough memory available to complete this command
		/// </summary>
		NoMemory = 0x80100006L,

		/// <summary>
		/// SCARD_F_WAITED_TOO_LONG
		/// An internal consistency timer has expired.
		/// </summary>
		WaitedTooLong = 0x80100007L,

		/// <summary>
		/// SCARD_E_INSUFFICIENT_BUFFER
		/// The data buffer to receive returned
		/// data is too small for the returned data.
		/// </summary>
		InsufficientBuffer = 0x80100008L,

		/// <summary>
		/// SCARD_E_UNKNOWN_READER
		/// The specified reader name is not recognized.
		/// </summary>
		UnknownReader = 0x80100009L,

		/// <summary>
		/// SCARD_E_TIMEOUT
		/// The user-specified timeout value has expired.
		/// </summary>
		Timeout = 0x8010000AL,

		/// <summary>
		/// SCARD_E_SHARING_VIOLATION
		/// The smart card cannot be accessed because
		/// of other connections outstanding.
		/// </summary>
		SharingViolation = 0x8010000BL,

		/// <summary>
		/// SCARD_E_NO_SMARTCARD
		/// The operation requires a Smart Card, but no
		/// Smart Card is currently in the device.
		/// </summary>
		NoSmartCard = 0x8010000CL,

		/// <summary>
		/// SCARD_E_UNKNOWN_CARD
		/// The specified smart card name is not recognized.
		/// </summary>
		UnknownCard = 0x8010000DL,

		/// <summary>
		/// SCARD_E_CANT_DISPOSE
		/// The system could not dispose of the media
		/// in the requested manner.
		/// </summary>
		CantDispose = 0x8010000EL,

		/// <summary>
		/// SCARD_E_PROTO_MISMATCH
		/// The requested protocols are incompatible with the protocol currently in use with the smart card.
		/// </summary>
		ProtoMismatch = 0x8010000FL,

		/// <summary>
		/// SCARD_E_NOT_READY
		/// The reader or smart card is not ready to accept commands.
		/// </summary>
		NotReady = 0x80100010L,

		/// <summary>
		/// SCARD_E_INVALID_VALUE
		/// One or more of the supplied parameters values could not be properly interpreted.
		/// </summary>
		InvlaidValue = 0x80100011L,

		/// <summary>
		/// SCARD_E_SYSTEM_CANCELLED
		/// The action was cancelled by the system, presumably to log off or shut down.
		/// </summary>
		SystemCancelled = 0x80100012L,

		/// <summary>
		/// SCARD_F_COMM_ERROR
		/// An internal communications error has been detected.
		/// </summary>
		CommError = 0x80100013L,

		/// <summary>
		/// SCARD_F_UNKNOWN_ERROR
		/// An internal error has been detected, but the source is unknown.
		/// </summary>
		UnknownError = 0x80100014L,

		/// <summary>
		/// SCARD_E_INVALID_ATR
		/// An ATR obtained from the registry is not a valid ATR string.
		/// </summary>
		InvalidAtr = 0x80100015L,

		/// <summary>
		/// SCARD_E_NOT_TRANSACTED
		/// An attempt was made to end a non-existent transaction.
		/// </summary>
		NotTransacted = 0x80100016L,

		/// <summary>
		/// SCARD_E_READER_UNAVAILABLE
		/// The specified reader is not currently available for use.
		/// </summary>
		ReaderUnavailable = 0x80100017L,

		/// <summary>
		/// SCARD_P_SHUTDOWN
		/// The operation has been aborted to allow the server application to exit.
		/// </summary>
		Shutdown = 0x80100018L,

		/// <summary>
		/// SCARD_E_PCI_TOO_SMALL
		/// The PCI Receive buffer was too small.
		/// </summary>
		PciTooSmall = 0x80100019L,

		/// <summary>
		/// SCARD_E_READER_UNSUPPORTED
		/// The reader driver does not meet minimal requirements for support.
		/// </summary>
		ReaderUnsupported = 0x8010001AL,

		/// <summary>
		/// SCARD_E_DUPLICATE_READER
		/// The reader driver did not produce a unique reader name.
		/// </summary>
		DuplicateReader = 0x8010001BL,

		/// <summary>
		/// SCARD_E_CARD_UNSUPPORTED
		/// The smart card does not meet minimal requirements for support.
		/// </summary>
		CardUnsupported = 0x8010001CL,

		/// <summary>
		/// SCARD_E_NO_SERVICE
		/// The Smart card resource manager is not running.
		/// </summary>
		NoService = 0x8010001DL,

		/// <summary>
		/// SCARD_E_SERVICE_STOPPED
		/// The Smart card resource manager has shut down.
		/// </summary>
		ServiceStopped = 0x8010001EL,

		/// <summary>
		/// SCARD_E_UNEXPECTED
		/// An unexpected card error has occurred.
		/// </summary>
		Unexpected = 0x8010001FL,

		/// <summary>
		/// SCARD_E_ICC_INSTALLATION
		/// No Primary Provider can be found for the smart card.
		/// </summary>
		ICCInstallation = 0x80100020L,

		/// <summary>
		/// SCARD_E_ICC_CREATEORDER
		/// The requested order of object creation is not supported.
		/// </summary>
		ICCCreateOrder = 0x80100021L,

		/// <summary>
		/// SCARD_E_UNSUPPORTED_FEATURE
		/// This smart card does not support the requested feature.
		/// </summary>
		UnsupportedFeature = 0x80100022L,

		/// <summary>
		/// SCARD_E_DIR_NOT_FOUND
		/// The identified directory does not exist in the smart card.
		/// </summary>
		DirectoryNotFound = 0x80100023L,

		/// <summary>
		/// SCARD_E_FILE_NOT_FOUND
		/// The identified file does not exist in the smart card.
		/// </summary>
		FileNotFound = 0x80100024L,

		/// <summary>
		/// SCARD_E_NO_DIR
		/// The supplied path does not represent a smart card directory.
		/// </summary>
		NoDirectory = 0x80100025L,

		/// <summary>
		/// SCARD_E_NO_FILE
		/// The supplied path does not represent a smart card file.
		/// </summary>
		NoFile = 0x80100026L,

		/// <summary>
		/// SCARD_E_NO_ACCESS
		/// Access is denied to this file.
		/// </summary>
		NoAccess = 0x80100027L,

		/// <summary>
		/// SCARD_E_WRITE_TOO_MANY
		/// The smartcard does not have enough memory to store the information.
		/// </summary>
		WriteTooMany = 0x80100028L,

		/// <summary>
		/// SCARD_E_BAD_SEEK
		/// There was an error trying to set the smart card file object pointer.
		/// </summary>
		BadSeek = 0x80100029L,

		/// <summary>
		/// SCARD_E_INVALID_CHV
		/// The supplied PIN is incorrect.
		/// </summary>
		InvalidChv = 0x8010002AL,

		/// <summary>
		/// SCARD_E_UNKNOWN_RES_MNG
		/// An unrecognized error code was returned from a layered component.
		/// </summary>
		UnknownResMng = 0x8010002BL,

		/// <summary>
		/// SCARD_E_NO_SUCH_CERTIFICATE
		/// The requested certificate does not exist.
		/// </summary>
		NoSuchCertificate = 0x8010002CL,

		/// <summary>
		/// SCARD_E_CERTIFICATE_UNAVAILABLE
		/// The requested certificate could not be obtained.
		/// </summary>
		CertificateUnavailible = 0x8010002DL,

		/// <summary>
		/// SCARD_E_NO_READERS_AVAILABLE
		/// Cannot find a smart card reader.
		/// </summary>
		NoReadersAvailible = 0x8010002EL,

		/// <summary>
		/// SCARD_E_COMM_DATA_LOST
		/// A communications error with the smart card has been detected.  Retry the operation.
		/// </summary>
		CommDataLost = 0x8010002FL,

		/// <summary>
		/// SCARD_E_NO_KEY_CONTAINER
		/// The requested key container does not exist on the smart card.
		/// </summary>
		NoKeyContainer = 0x80100030L,

		/// <summary>
		/// SCARD_E_SERVER_TOO_BUSY
		/// The Smart card resource manager is too busy to complete this operation.
		/// </summary>
		ServerTooBusy = 0x80100031L,

		/// <summary>
		/// SCARD_E_PIN_CACHE_EXPIRED
		/// he smart card PIN cache has expired.
		/// </summary>
		PinCacheExpired = 0x80100032L,

		/// <summary>
		/// SCARD_E_NO_PIN_CACHE
		/// The smart card PIN cannot be cached.
		/// </summary>
		NoPinCache = 0x80100033L,

		/// <summary>
		/// SCARD_E_READ_ONLY_CARD
		/// The smart card is read only and cannot be written to.
		/// </summary>
		ReadOnlyCard = 0x80100034L,

		/// <summary>
		/// SCARD_W_UNSUPPORTED_CARD
		/// The reader cannot communicate with the smart card, due to ATR configuration conflicts.
		/// </summary>
		UnsupportedCard = 0x80100065L,

		/// <summary>
		/// SCARD_W_UNRESPONSIVE_CARD
		/// The smart card is not responding to a reset.
		/// </summary>
		UnresponsiveCard = 0x80100066L,

		/// <summary>
		/// SCARD_W_UNPOWERED_CARD
		/// Power has been removed from the smart card, so that further communication is not possible.
		/// </summary>
		UnpoweredCard = 0x80100067L,

		/// <summary>
		/// SCARD_W_RESET_CARD
		/// The smart card has been reset, so any shared state information is invalid.
		/// </summary>
		ResetCard = 0x80100068L,

		/// <summary>
		/// SCARD_W_REMOVED_CARD
		/// The smart card has been removed, so that further communication is not possible.
		/// </summary>
		RemovedCard = 0x80100069L,

		/// <summary>
		/// SCARD_W_SECURITY_VIOLATION
		/// Access was denied because of a security violation.
		/// </summary>
		SecurityViolation = 0x8010006AL,

		/// <summary>
		/// SCARD_W_WRONG_CHV
		/// The card cannot be accessed because the wrong PIN was presented.
		/// </summary>
		WrongChv = 0x8010006BL,

		/// <summary>
		/// SCARD_W_CHV_BLOCKED
		/// The card cannot be accessed because the maximum number of PIN entry attempts has been reached.
		/// </summary>
		ChvBlocked = 0x8010006CL,

		/// <summary>
		/// SCARD_W_EOF
		/// The end of the smart card file has been reached.
		/// </summary>
		Eof = 0x8010006DL,

		/// <summary>
		/// SCARD_W_CANCELLED_BY_USER
		/// The action was cancelled by the user.
		/// </summary>
		CancelledByUser = 0x8010006EL,

		/// <summary>
		/// SCARD_W_CARD_NOT_AUTHENTICATED
		/// No PIN was presented to the smart card.
		/// </summary>
		CardNotAuthenticated = 0x8010006FL,

		/// <summary>
		/// SCARD_W_CACHE_ITEM_NOT_FOUND
		/// The requested item could not be found in the cache.
		/// </summary>
		CacheItemNotFound = 0x80100070L,

		/// <summary>
		/// SCARD_W_CACHE_ITEM_STALE
		/// The requested cache item is too old and was deleted from the cache.
		/// </summary>
		CacheItemStale = 0x80100071L,

		/// <summary>
		/// SCARD_W_CACHE_ITEM_TOO_BIG
		/// The new cache item exceeds the maximum per-item size defined for the cache.
		/// </summary>
		CacheItemTooBig = 0x80100072L,
	}
}
